//
//  main.cpp
//  selectionSort
//
//  Created by Shane on 17/9/18.
//  Copyright © 2017年 Shane. All rights reserved.
//

#include <iostream>
using namespace std;


void selectionSort(int a[], int n){
    for (int i = 0; i < n; ++i) {
        int index = i;
        for (int j = i+1; j < n; ++j) {
            if (a[j] < a[index]) {
                index = j;
            }
        }
        if (index != i) {
            std::swap(a[i], a[index]);
        }
    }
    
}



int main(int argc, const char * argv[]) {
    int a[] = {10,7,8,9,4, 2, 3, 6, 5,1,0, 12, 11};
    int count = sizeof(a)/sizeof(a[0]);
    selectionSort(a, count);
    return 0;
}


